// packageA/pages/mainDetailMore/mainDetailMore.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    isPhone: false,
    callindex: 0,
    IsShopVideo: 0
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.queryMoreList();
    this.queryServicePhone()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    var FjLoginLog = wx.getStorageSync('FjLoginLog');
    var that = this
    var api_input = {
      uid: FjLoginLog.UID,
      upwd: FjLoginLog.UPwd
    }
    app.getDaoPost('api/FeijiuApp/Post_FJ_UserInfoByUID', api_input, function (r) {
      console.log(JSON.parse(app.aesDec(r.data)))
      if (r.code == 200) {
        var arr = JSON.parse(app.aesDec(r.data));
        that.setData({
          IsShopVideo: arr.IsShopVideo,
          ZuLinMess: arr.ZuLinMess
        })
      }
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  },
  queryMoreList(e) {
    let that = this
    app.getDaoPost('api/FeijiuApp/Feijiu_Get_MoreFuWu', {}, r => {
      console.log(r, '二级页面--更多服务')
      if (r.code == 200) {
        that.setData({
          list: r.data

        })
      } else {
        wx.showToast({
          title: r.message,
          icon: 'none'
        })
      }
    })
  },
  jumpDetail(e) {
    console.log('e===', e)
    var url = e.currentTarget.dataset.url;
    console.log(url)
    if (url.substring(0, 20) == 'https://m.feijiu.net' || url.substring(0, 19) == 'http://m.feijiu.net' || url.substring(0, 19) == 'https://s.jupai.net') {
      wx.navigateTo({
        url: '/pages/other/web',
        success: function (res) {
          // 通过 eventChannel 向被打开页面传送数据
          res.eventChannel.emit('acceptDataFromOpenerPage', {
            url: url
          })
        }
      })
    } else if (url == 25002 || url == 25003) {
      wx.navigateTo({
        url: '/pages/gongqiuxinxi/index',
      })
    } else if (url == 25004) {
      wx.navigateTo({
        url: '/packageA/pages/zichanchuzhi/index',
      })
    } else if (url == 25005) {
      wx.reLaunch({
        url: '/pages/zhaobiaogonggao/index',
      })
    } else if (url == 25006) {
      wx.navigateTo({
        url: '/packageA/pages/index/index',
      })
    } else if (url == 25013) { //客服
      this.setData({
        isPhone: true,
        callindex: 0
      })
    } else if (url == 25017) { //投诉热线
      this.setData({
        isPhone: true,
        callindex: 2
      })
    } else if (url == 25015) {//租赁
      // if (this.data.IsShopVideo != 1) {
      //   app.tishi(this.data.ZuLinMess);
      //   return false;
      // }
      if (app.checkFjLogin()) {
        wx.navigateTo({
          url: '/packageB/pages/leaseRelease/leaseIndex/leaseIndex',
        })
      } else {
        wx.navigateTo({
          url: '/pages/login/index'
        });
      }
    }
    else {
      wx.showToast({
        title: '此功能仅限app使用',
        icon: 'none'
      })
    }
  },
  closePhone() {
    this.setData({
      isPhone: false
    })
  },
  callPhone(e) {
    let index = e.currentTarget.dataset.index,
      phone = e.currentTarget.dataset.phone
    this.setData({
      callindex: index
    })
    wx.makePhoneCall({
      phoneNumber: phone
    })
  },
  queryServicePhone(type = '') {
    app.getDaoPost('api/FeijiuApp/Feijiu_Get_FJTel', { type: type }, r => {
      console.log(r, '客服电话')
      if (r.code == 200) {
        this.setData({
          servicePhone: r.data
        })
      }
    })
  }
})